package com.lanxin.xxform.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class SiteController {

    @GetMapping("")
    public String login() {
        return "site/login";
    }

    @GetMapping("paper.html")
    public String paper(
        @RequestParam(defaultValue = "") String id,
        ModelMap map
    ) {
        map.put("paperId", id);
        return "site/paper";
    }

    @GetMapping("/error/403")
    public String errorNotRole(ModelMap map) {
        map.put("title", "403");
        map.put("message", "您尚未登录，或没有权限查看当前页面内容");
        map.put("tips", "Forbidden!");
        return "site/error";
    }

    @GetMapping("/error/404")
    public String errorNotFound(ModelMap map) {
        map.put("title", "404");
        map.put("message", "您要访问的页面不存在");
        map.put("tips", "Not Found!");
        return "site/error";
    }

    @GetMapping("/error/405")
    public String errorMethodError(ModelMap map) {
        map.put("title", "405. ");
        map.put("message", "您访问的页面或者接口姿势不对");
        map.put("tips", "Method Not Allowed!");
        return "site/error";
    }

    @GetMapping("/error/500")
    public String errorServerError(ModelMap map) {
        map.put("title", "500. Oh Shit!");
        map.put("message", "我们遇到了一点点麻烦，等待处理");
        map.put("tips", "Server Error!");
        return "site/error";
    }
    
}
